package com.zh.kotlin_mvvm.fragment

import android.annotation.SuppressLint
import android.content.Context
import android.os.Bundle
import androidx.core.content.ContextCompat
import com.vanniktech.emoji.EmojiEditText
import com.vanniktech.emoji.EmojiTheming
import com.vanniktech.emoji.search.NoSearchEmoji
import com.zh.common.base.BaseFragment
import com.zh.kotlin_mvvm.R
import com.zh.kotlin_mvvm.databinding.FragmentEmojiBinding

class EmojiFragment : BaseFragment<FragmentEmojiBinding>() {

    var editView: EmojiEditText? = null

    override fun initView(savedInstanceState: Bundle?) {

        val context: Context = this.requireContext()
        @SuppressLint("ResourceAsColor") val emojiTheming = EmojiTheming(
            ContextCompat.getColor(context, R.color.color_white),
            ContextCompat.getColor(context, R.color.colorGreyLight),
            ContextCompat.getColor(context, R.color.colorPrimary),
            ContextCompat.getColor(context, R.color.colorAccent),
            ContextCompat.getColor(context, R.color.emoji_text_color),
            ContextCompat.getColor(context, R.color.emoji_text_secondary_color)
        )
        viewBinding.emojiView.setUp(
            rootView = viewBinding.root,
            onEmojiClickListener = null,
            onEmojiBackspaceClickListener = null,
            editText = editView,
            theming = emojiTheming,
            searchEmoji= NoSearchEmoji
        )
    }


    override fun onDestroyView() {
        viewBinding.emojiView.tearDown()
        super.onDestroyView()
    }
}